using System;
using SmartPeople.Framework.SecuritySpace;

namespace SmartPeople.Framework.SecuritySpace
{
    public interface ISecurityRoleProvider
    {
        /// <summary>
        /// Creates the role.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <returns></returns>
        ISecurityRole CreateRole(string roleName);

        /// <summary>
        /// Creates the role.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <param name="description">The description.</param>
        /// <param name="comment">The comment.</param>
        /// <returns></returns>
        ISecurityRole CreateRole(string roleName, string description, string comment);

        /// <summary>
        /// Creates the role.
        /// </summary>
        /// <param name="roleGuid">The role GUID.</param>
        /// <returns></returns>
        ISecurityRole CreateRole(Guid roleGuid);

        /// <summary>
        /// Gets all roles.
        /// </summary>
        /// <returns></returns>
        ISecurityRole[] GetAllRoles();

        /// <summary>
        /// Gets the role.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <returns></returns>
        ISecurityRole GetRole(string roleName);

        /// <summary>
        /// Gets the roles.
        /// </summary>
        /// <param name="roleNames">The role names.</param>
        /// <returns></returns>
        ISecurityRole[] GetRoles(string[] roleNames);

        /// <summary>
        /// Gets the role.
        /// </summary>
        /// <param name="roleguid">The roleguid.</param>
        /// <returns></returns>
        ISecurityRole GetRole(Guid roleguid);

        /// <summary>
        /// Updates the role.
        /// </summary>
        /// <param name="role">The role.</param>
        void UpdateRole(ISecurityRole role);

        /// <summary>
        /// Roles the exists.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <returns></returns>
        bool RoleExists(string roleName);

        /// <summary>
        /// Roles the exists.
        /// </summary>
        /// <param name="roleGuid">The role GUID.</param>
        /// <returns></returns>
        bool RoleExists(Guid roleGuid);

        /// <summary>
        /// Deletes the role.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <returns></returns>
        bool DeleteRole(string roleName);

        /// <summary>
        /// Deletes the role.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <param name="throwOnPopulatedRole">if set to <c>true</c> [throw on populated role].</param>
        /// <returns></returns>
        bool DeleteRole(string roleName,
                        bool throwOnPopulatedRole);

        /// <summary>
        /// Adds the users to roles.
        /// </summary>
        /// <param name="usernames">The usernames.</param>
        /// <param name="roleNames">The role names.</param>
        void AddUsersToRoles(string[] usernames, string[] roleNames);

        /// <summary>
        /// Removes the users from roles.
        /// </summary>
        /// <param name="userNames">The user names.</param>
        /// <param name="roleNames">The role names.</param>
        void RemoveUsersFromRoles(string[] userNames, string[] roleNames);

        //string[] FindUsersInRole(string roleName, string usernameToMatch);
        //string[] GetAllRoles();


        /// <summary>
        /// Gets the roles for user.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <returns></returns>
        string[] GetRolesForUser(string userName);


        /// <summary>
        /// Gets the roles for user.
        /// </summary>
        /// <param name="userToken">The user token.</param>
        /// <returns></returns>
        string[] GetRolesForUser(IToken userToken);


        /// <summary>
        /// Gets the users in role.
        /// </summary>
        /// <param name="roleName">Name of the role.</param>
        /// <returns></returns>
        string[] GetUsersInRole(string roleName);


        /// <summary>
        /// Determines whether [is user in role] [the specified user name].
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="roleName">Name of the role.</param>
        /// <returns>
        /// 	<c>true</c> if [is user in role] [the specified user name]; otherwise, <c>false</c>.
        /// </returns>
        bool IsUserInRole(string userName, string roleName);


        /// <summary>
        /// Gets the count.
        /// </summary>
        /// <value>The count.</value>
        int Count { get; }


        /// <summary>
        /// Clears this instance.
        /// </summary>
        void Clear();
    }
}